﻿if (typeof (DayPilot2) === 'undefined') {
    DayPilot2 = {};
}

DayPilot2.Message = function (id) {

    // default values
    this.hideAfter = 4000; // ms

    var This = this;
    this.id = id;

    this.show = function (html, className) {
        if (html == null) {
            return;
        }

        this.div = document.getElementById(id);

        this.div.innerHTML = html;
        this.div.style.display = '';
        if (className) {
            this.oldClassName = this.div.className;
            this.div.className = className;
        }

        if (this.timeout) {
            window.clearTimeout(this.timeout);
        }

        var delayedHide = function () { This.hide(); };

        this.timeout = window.setTimeout(delayedHide, this.hideAfter);

    };

    this.hide = function () {
        this.div.innerHTML = '';
        this.div.style.display = 'none';
        if (this.oldClassName) {
            this.div.className = this.oldClassName;
            this.oldClassName = null;
        }
    };
};
